
import 'package:yp/services/api.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';

import 'state.dart';

class MembershipCardHomePageLogic extends GetxController {
  final state = MembershipCardHomePageState();

  @override
  void onInit() {
    super.onInit();

    // 获取用户信息
    var params = {
      'access_token': SpUtil.getString('token'),
      'mobile': SpUtil.getString('number'),
    };
    Api.searchMember(params).listen((event) {
      if (event['code'] == 0) {
        state.userInformationData = event;
      } else {
        state.userInformationData = null;
      }
      state.controller1.refreshCompleted();
      update();
    });
  }


// 下拉 刷新
  void refreshData() {
    // 获取用户信息
    var params = {
      'access_token': SpUtil.getString('token'),
      'mobile': SpUtil.getString('number'),
    };
    Api.searchMember(params).listen((event) {
      if (event['code'] == 0) {
        state.userInformationData = event;
      } else {
        state.userInformationData = null;
      }
      state.controller1.refreshCompleted();
      update();
    });
  }


}